// MaxFlow.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <iostream>
#include <vector>


using namespace std;

const int maxn = 101;

int N;
int G[maxn][maxn];


vector<int> edges[maxn];

int find_path(int s, int t, int *pre)
{
	int* q = new int[N + 1];
	int* mark = new int[N + 1];

	for (int i = 0; i <= N; i++)
	{
		mark[i] = 0;
	}

	bool ok = false;

	int qt, qh, i, x;
	for (q[0] = s, qt = 0, qh = 1, mark[s] = 1; qt < qh; qt++)
	{		
		x = q[qt];

		for (vector<int>::iterator it = edges[x].begin(); it != edges[x].end(); ++it)
		{
			if (G[x][*it] > 0 && mark[*it] == 0)
			{

				mark[*it] = 1;
				pre[*it] = x;

				if (*it == t)
				{
					ok = true;
					break;
				}
				q[qh++] = *it;

			}
		}

		if (ok)
			break;

	}

	delete[] mark;
	delete[] q;

	if (ok)
		return 1;
	else
		return 0;
}

const int MAXN = 1001;

int Ford_Fulkerson(int s, int t )
{
	int F = 0;

	while(true)
	{
		int i=0, min = MAXN;

		int* pre = new int[N + 1];

		if (find_path(s, t, pre) == 0)
		{
			delete[] pre;

			return F;
		}


		for (i = t; i != s; i = pre[i])
		{
			if (G[pre[i]][i] < min)
			{
				min = G[pre[i]][i];
			}

		}

		for (i = t; i != s; i = pre[i])
		{
			G[pre[i]][i] -= min;
			G[i][pre[i]] += min;
		}

		F += min;

		delete[] pre;
	}

	return F;
}




int S, T;
int num;


int x1,x2,x3;

int times = 1;

int main()
{
	while (cin >> N && N != 0)
	{
		for (int i = 1; i <= N; i++)
			edges[i].clear();

		memset(G, 0, sizeof(G));

		cin >> S >> T >> num;
		for (int i = 0; i < num; i++)
		{
			cin >> x1 >> x2 >> x3;
			G[x1][x2] += x3;
			G[x2][x1] += x3;

			edges[x1].push_back(x2);
			edges[x2].push_back(x1);
		}

		int F = Ford_Fulkerson(S,T);
		
		cout << "Network " << times++ << endl;
		cout << "The bandwidth is " << F << "." << endl;
		cout << endl;

	}

	

	return 0;
}